import base64
import random
import requests
from django.shortcuts import render, redirect
from django.http import HttpResponseRedirect, JsonResponse
from django.views.decorators.csrf import csrf_exempt


# @csrf_exempt
# def LoginView(request):
#     if request.method == 'POST':
#         username = request.POST['username']
#         password = request.POST['password']
#         if 1+1 > 0:
#             return HttpResponseRedirect('/')  # 登录成功后重定向到首页
#         else:
#             context = {'error_message': '认证失败。身份认证网关返回的身份证信息为空。'}
#             return render(request, 'index/login.html', context)
#         except Exception as e:
#             print("e")
#             print(e)
#             context = {'error_message': '认证失败。身份认证网关通信失败。'}
#             return render(request, 'index/login.html', context)
#     else:
#         return render(request, 'index/login.html')


# def Logout(request):
#     # 注销用户，登出操作
#     if request.session.get('member'):
#         del request.session['member']
#     # 重定向到登录页面
#     return HttpResponseRedirect('/login')


# def ErrorPage(request):
#     return render(request, 'index/error.html')


def IndexView(request, id=None):
    context = {}
    context['member'] = "member"
    return render(request, 'index/index.html', context)

